package com.ruoyi.web.util;

import com.ruoyi.wash.enums.CallRecordResultEnum;
import com.ruoyi.wash.enums.DaoZhaServersEnum;
import com.ruoyi.wash.enums.EnvionInfoEnum;
import com.ruoyi.wash.enums.LianTuoFuServersEnum;
import com.ruoyi.wash.enums.ThirdSystemInfoEnum;
import com.ruoyi.web.dto.DictionaryDto;
import org.springframework.ui.ModelMap;

import java.util.ArrayList;
import java.util.List;

/**
 * 软件著作权:王艳明
 * 系统名称:SpringBoot后台管理系统
 *
 * @author WangYanming
 * @ClassName 类:WashModelMapUtil.java
 * @Description 功能描述:WashModelMapUtil
 * @Version 1.0
 * @date 2024-05-05 下午 06:09
 */
public class WashModelMapUtil {

    /**
     * setEnvirons
     *
     * @param modelMap
     */
    public static void setEnvirons(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        List<DictionaryDto> environs = new ArrayList<>();
        for (EnvionInfoEnum environ : EnvionInfoEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setCode(environ.getCode());
            dto.setName(environ.getName());
            environs.add(dto);
        }
        modelMap.put("environs", environs);
    }

    /**
     * setThirdSystems
     *
     * @param modelMap
     */
    public static void setThirdSystems(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        List<DictionaryDto> thirdSystems = new ArrayList<>();
        for (ThirdSystemInfoEnum thirdSystem : ThirdSystemInfoEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setCode(thirdSystem.getCode());
            dto.setName(thirdSystem.getName());
            thirdSystems.add(dto);
        }
        modelMap.put("thirdSystems", thirdSystems);
    }

    /**
     * setServersDZ
     *
     * @param modelMap
     */
    public static void setServersDZ(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        List<DictionaryDto> serversDZ = new ArrayList<>();
        for (DaoZhaServersEnum server : DaoZhaServersEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setCode(server.getCode());
            dto.setName(server.getName());
            serversDZ.add(dto);
        }
        modelMap.put("serversDZ", serversDZ);
    }

    /**
     * setServersDZ
     *
     * @param modelMap
     */
    public static void setServerDZSelected(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        modelMap.put("serverDZ", DaoZhaServersEnum.SWAGGER_VEHICLE_IN.getCode());
    }

    /**
     * setServersDZ
     *
     * @param modelMap
     */
    public static void setServerLTFSelected(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        modelMap.put("serverLTF", LianTuoFuServersEnum.OPEN_MEMBER_GET.getCode());
    }

    /**
     * setServersLTF
     *
     * @param modelMap
     */
    public static void setServersLTF(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        List<DictionaryDto> serversLTF = new ArrayList<>();
        for (LianTuoFuServersEnum server : LianTuoFuServersEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setCode(server.getCode());
            dto.setName(server.getName());
            serversLTF.add(dto);
        }
        modelMap.put("serversLTF", serversLTF);
    }

    /**
     * setServersAll
     *
     * @param modelMap
     */
    public static void setServersAll(ModelMap modelMap) {
        if (modelMap == null) {
            modelMap = new ModelMap();
        }
        List<DictionaryDto> servers = new ArrayList<>();
        for (DaoZhaServersEnum server : DaoZhaServersEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setName(server.getName());
            dto.setCode(server.getCode());
            servers.add(dto);
        }
        for (LianTuoFuServersEnum server : LianTuoFuServersEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setName(server.getName());
            dto.setCode(server.getCode());
            servers.add(dto);
        }
        modelMap.put("servers", servers);
    }

    /**
     * setCallStatusList
     *
     * @param modelMap
     */
    public static void setCallStatusList(ModelMap modelMap) {
        List<DictionaryDto> callStatusList = new ArrayList<>();
        for (CallRecordResultEnum server : CallRecordResultEnum.values()) {
            DictionaryDto dto = new DictionaryDto();
            dto.setCode(server.getCode().toString());
            dto.setName(server.getMessage());
            callStatusList.add(dto);
        }
        modelMap.put("callStatusList", callStatusList);
    }

}
